﻿using System.Collections.Generic;

using VSTalk.Engine.Core.Data;

namespace VSTalk.Engine.Core.Disco.Caps
{
    public class CapsDiscoveryDataProvider : ICapsDiscoveryDataAccess
    {
        private readonly ICapsDicoveryDA _dicoveryDA = new CapsDiscoveryDA();

        public CapsDiscoveryDataProvider()
        {
            Init();
        }

        private void Init()
        {
            DatabaseManager.RegisterDA(_dicoveryDA);
        }

        private static IDatabaseManager DatabaseManager
        {
            get { return AppServices.Get<IDatabaseManager>(); }
        }

        public bool HasCaps(CapsInfo info)
        {
            return _dicoveryDA.HasCaps(info.Node, info.Hash, info.Version);
        }

        public void RecordFeatures(CapsInfo info, IList<string> features)
        {
            _dicoveryDA.RecordFeatures(info.Node, info.Hash, info.Version, features);
        }

        public bool HasFeature(CapsInfo capsInfo, string uri)
        {
            return _dicoveryDA.HasFeature(capsInfo.Node, capsInfo.Hash, capsInfo.Version, uri);
        }
    }
}